/**
 *
 */
package com.ean.backpack.controller;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.log4j.Logger;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.beans.propertyeditors.StringTrimmerEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;

/**
 *
 *
 * @author valentin
 */
public abstract class AbstractController {
	protected static Logger logger = Logger.getLogger(AbstractController.class);

	protected String dateFormat = "dd/MM/yyyy";

	@InitBinder
	public void allowEmptyDateBinding(WebDataBinder binder) {
		// Allow for null values in date fields.
		binder.registerCustomEditor(Date.class, new CustomDateEditor(
				new SimpleDateFormat(dateFormat), true));
		// tell spring to set empty values as null instead of empty string.
		binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));
	}

}
